<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	function _initViewHelpers()
	{
		
		
		
		
		$this->bootstrap('layout');
		$layout = $this->getResource('layout');
		$view = $layout->getView();
		$view->doctype('XHTML1_STRICT');
		$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
		$view->headMeta()->appendName('keywords', 'Service-Sicherheit Broker');
		$view->headLink()->appendStylesheet('https://localhost/myprojects/broker/public/_files/css/styles.css');
		$view->headTitle()->setSeparator(' - ');
		$view->headTitle('Service-Sicherheit Broker');
		
				
		//Autoload Setup
		
		
		
		require_once 'Zend/Loader.php';
		
	Zend_Loader::registerAutoload();
		

	//Include Pfade setzen
	set_include_path('.' . PATH_SEPARATOR .
		 '../library' . PATH_SEPARATOR .
		 '../application/models/' . PATH_SEPARATOR .
	 get_include_path());

		
     //DB SETUP
		
        $params = array('host' => '127.0.0.1',
        'username'=> 'root',
        'password' => '',
        'dbname' => 'broker');

        
        $db = Zend_Db::factory('PDO_MYSQL', $params); // erzeugt DB Adapter für MYSQL
        
        
        Zend_Db_Table::setDefaultAdapter($db); //Adapter setzen!
        
       
        // Festlegung des Controller Verzeichnisses für die Module 'default' und 'api'
        
        $frontController = Zend_Controller_Front::getInstance();
		$frontController->setControllerDirectory(array('default'=>'../application/controllers',
														'api'=>'../application/modules/api/controllers'));
		
				
		// RESTful Route für das Modul 'api'		
		$restRoute = new Zend_Rest_Route($frontController, array(), array('api'));
		$frontController->getRouter()->addRoute('rest', $restRoute);
		
			// Nutzerdefinierte RESTful Routes für die api
			
			
			$profileRoute = new Zend_Controller_Router_Route(
														':module/provider/:id/profile/:profileID', 
														array('module'=>'api', 'controller'=>'profile', 'action'=>'get'));
		
			$frontController->getRouter()->addRoute('profile', $profileRoute);
		
			$profileIndexRoute = new Zend_Controller_Router_Route(
														':module/provider/:id/profile/', 
														array('module'=>'api', 'controller'=>'profile', 'action'=>'index'));

			$frontController->getRouter()->addRoute('profileToIndex', $profileIndexRoute);
			
			
//			$offerRoute = new Zend_Controller_Router_Route(':module/provider/:id/profile/:profileID/offer',
//															array('module' => 'api', 'controller' => 'offer', 'action'=>'get'));
//															
//			$frontController->getRouter()->addRoute('offer', $offerRoute);
			
			$restOffer = new Zend_Rest_Route($frontController, array(), array('api' => array('offer')));
			$frontController->getRouter()->addRoute('offer', $restOffer);
//		
//			$restExpansion = new Zend_Rest_Route($frontController, array(), array('api' => array('request')));
//			$frontController->getRouter()->addRoute('expansion', $restExpansion);
//		
			//Plugin registrieren
			$frontController->registerPlugin(new Zend_Controller_Plugin_PutHandler());
			

		
		
	}
}
